﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using DAL;

namespace DAL
{
    public class TypesumfrationDal
    {

        TBToList<ScoreAdornEntity> dtToScoreAdorn = new TBToList<ScoreAdornEntity>();


        #region 实例化一个sqlhelper
        private readonly SQLHelper sqlhelper = null;
        /// <summary>
        /// 实例化一个sqlhelper
        /// </summary>
        public TypesumfrationDal()
        {
            sqlhelper = new SQLHelper();

        }
        #endregion

        #region word类汇总总分-李芬

        /// <summary>
        /// word类汇总总分
        /// </summary>
        /// <param name="studentinfo"></param>
        /// <returns></returns>
        public DataTable wordsumfrationdal(String studentID, string TimeTamp)
        {
            String which = selectCollegeID(studentID).ToString();
            //查询学生的试卷类型/类型总分值
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                        new SqlParameter("@tamtamp", TimeTamp )};
            string sumText = "select sum(convert(float,Fration)) from WordQuestionRecordEntity_" + which + " where StudentID=@studentID and TimeStamp=@tamtamp group by StudentID";

            DataTable wordsumFrationDt;
            wordsumFrationDt = sqlhelper.ExecuteQuery(sumText, paras, CommandType.Text);
            string sumFration;
            if (wordsumFrationDt.Rows.Count > 0)
            {
                sumFration = wordsumFrationDt.Rows[0][0].ToString();
            }
            else
            {
                sumFration = "0";
            }



            //查询PaperType
            SqlParameter[] parastype = new SqlParameter[] { new SqlParameter("@studentID", studentID) };
            string papertypeText = "select PaperType from WordQuestionRecordEntity_" + which + " where StudentID=@studentID ";

            DataTable wordpapertypeDT;
            wordpapertypeDT = sqlhelper.ExecuteQuery(papertypeText, parastype, CommandType.Text);
            string paperType;
            if (wordpapertypeDT.Rows.Count > 0)
            {
                paperType = wordpapertypeDT.Rows[0][0].ToString();
            }
            else
            {
                paperType = "0";
            }


            //在WordSumFration表中插入数据
            //DateTime dtime = System.DateTime.Now

            SqlParameter[] parasinsertword = new SqlParameter[]{ new SqlParameter("@StudentID",studentID),new SqlParameter("@PaperType",paperType),new SqlParameter("@QuestionTypeID","NULL"),new SqlParameter("@sumfartion",sumFration),new SqlParameter("@TimeStamp",TimeTamp)
            };
            string insertword = "insert into WordSumFration values(@StudentID,@PaperType,@QuestionTypeID,@sumfartion,@TimeStamp)";
            int numword = sqlhelper.ExecuteNonQuery(insertword, parasinsertword, CommandType.Text);
            if (numword > 0)
            {
                return wordsumFrationDt;
            }
            return null;
        }
        #endregion
        #region excel类汇总总分

        /// <summary>
        /// excel类汇总总分-李芬
        /// 
        /// </summary>
        /// <param name="studentinfo"></param>
        /// <returns></returns>
        public DataTable excelsumfrationdal(String studentID, string TimeTamp)
        {
            String which = selectCollegeID(studentID).ToString();

            //查询学生的试卷类型/类型总分值
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                        new SqlParameter ("@tamtamp",TimeTamp )};
            string sumText = "select  sum(convert(float,Fration))  from ExcelQuestionRecordEntity_" + which + " where StudentID=@studentID and TimeStamp=@tamtamp group by StudentID";

            DataTable excelsumFrationDt;
            excelsumFrationDt = sqlhelper.ExecuteQuery(sumText, paras, CommandType.Text);
            string sumFration;
            //sumFration = excelsumFrationDt.Rows[0][0].ToString()
            if (excelsumFrationDt.Rows.Count > 0)
            {
                sumFration = excelsumFrationDt.Rows[0][0].ToString();
            }
            else
            {
                sumFration = "0";
            }



            //在ExcelSumFration表中插入数据
            //DateTime dtime = System.DateTime.Now
            SqlParameter[] parasinsertexcel = new SqlParameter[]{ new SqlParameter("@StudentID",studentID),new SqlParameter("@PaperType","NULL"),new SqlParameter("@QuestionTypeID",which),new SqlParameter("@sumfartion",sumFration),new SqlParameter("@TimeStamp",TimeTamp)
            };
            string insertexcel = "insert into ExcelSumFration values(@StudentID,@PaperType,@QuestionTypeID,@sumfartion,@TimeStamp)";
            int numexcel = sqlhelper.ExecuteNonQuery(insertexcel, parasinsertexcel, CommandType.Text);

            if (numexcel > 0)
            {
                return excelsumFrationDt;
            }
            else
            {
                return null;
            }

        }
        #endregion
        //#region excel类汇总总分

        ///// <summary>
        ///// excel类汇总总分-李芬
        ///// 
        ///// </summary>
        ///// <param name="studentinfo"></param>
        ///// <returns></returns>
        //public DataTable excelsumfrationdal(String studentID, string TimeTamp)
        //    String which = selectCollegeID(studentID).ToString()

        //    //查询学生的试卷类型/类型总分值
        //    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@studentID", studentID),
        //                                                new SqlParameter ("@tamtamp",TimeTamp )
        //    string sumText = "select  sum(convert(float,Fration))  from ExcelQuestionRecordEntity_" + which + " where StudentID=@studentID and TimeStamp=@tamtamp group by StudentID"

        //    DataTable excelsumFrationDt
        //    excelsumFrationDt = sqlhelper.ExecuteQuery(sumText, paras, CommandType.Text)
        //    string sumFration

        //    sumFration = excelsumFrationDt.Rows[0][0].ToString()


        //    //在ExcelSumFration表中插入数据
        //    //DateTime dtime = System.DateTime.Now
        //    SqlParameter[] parasinsertexcel = new SqlParameter[]{ new SqlParameter("@StudentID",studentID),new SqlParameter("@PaperType","NULL"),new SqlParameter("@QuestionTypeID",which),new SqlParameter("@sumfartion",sumFration),new SqlParameter("@TimeStamp",TimeTamp)
        //    
        //    string insertexcel = "insert into ExcelSumFration values(@StudentID,@PaperType,@QuestionTypeID,@sumfartion,@TimeStamp)"
        //    int numexcel = sqlhelper.ExecuteNonQuery(insertexcel, parasinsertexcel, CommandType.Text)

        //    return excelsumFrationDt
        //#endregion

        #region win类汇总总分-李芬

        /// <summary>
        /// win类汇总总分
        /// </summary>
        /// <param name="studentinfo"></param>
        /// <returns></returns>
        public DataTable winsumfrationdal(String studentID, string TimeTamp)
        {
            String which = selectCollegeID(studentID).ToString();
            //查询学生的类型总分值
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                         new SqlParameter ("@tamtamp",TimeTamp )};
            string sumText = "select  sum(convert(float,fraction)) from WinQuestionRecordEntity_" + which + " where studentID=@studentID and timeStamp=@tamtamp group by studentID";
            DataTable winsumFrationDt;
            winsumFrationDt = sqlhelper.ExecuteQuery(sumText, paras, CommandType.Text);
            string sumFration;
            if (winsumFrationDt.Rows.Count > 0)
            {
                sumFration = winsumFrationDt.Rows[0][0].ToString();
                //在winSumFration表中插入数据
                //DateTime dtime = System.DateTime.Now
                SqlParameter[] parasinsertwin = new SqlParameter[]{ new SqlParameter("@StudentID",studentID),new SqlParameter("@PaperType","NULL"),new SqlParameter("@QuestionTypeID",which),new SqlParameter("@sumfartion",sumFration),new SqlParameter("@TimeStamp",TimeTamp)
            };
                string insertwin = "insert into WinSumFration values(@StudentID,@PaperType,@QuestionTypeID,@sumfartion,@TimeStamp)";
                int numwin = sqlhelper.ExecuteNonQuery(insertwin, parasinsertwin, CommandType.Text);
                if (numwin > 0)
                {
                    return winsumFrationDt;
                }
                else
                {
                    return null;
                }

            }
            else
            {
                return null;
            }
        }
        #endregion

        #region ppt类汇总总分-李芬

        /// <summary>
        /// ppt类汇总总分
        /// </summary>
        /// <param name="studentinfo"></param>
        /// <returns></returns>
        public DataTable pptsumfrationdal(String studentID, string TimeTamp)
        {
            String which = selectCollegeID(studentID).ToString();
            //查询学生的试卷类型/类型总分值
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                       new SqlParameter("@tamtamp", TimeTamp)};
            string sumText = "select sum(convert(float,Fration)) from PptQuestionRecordEntity_" + which + " where StudentID=@studentID and TimeStamp=@tamtamp group by StudentID";

            DataTable pptsumFrationDt;
            pptsumFrationDt = sqlhelper.ExecuteQuery(sumText, paras, CommandType.Text);
            string sumFration;
            if (pptsumFrationDt.Rows.Count > 0)
            {
                sumFration = pptsumFrationDt.Rows[0][0].ToString();
                //在pptSumFration表中插入数据
                //DateTime dtime = System.DateTime.Now
                SqlParameter[] parasinsertPPT = new SqlParameter[]{ new SqlParameter("@StudentID",studentID),new SqlParameter("@PaperType","NULL"),new SqlParameter("@QuestionTypeID",which),new SqlParameter("@sumfartion",sumFration),new SqlParameter("@TimeStamp",TimeTamp)
            };
                string insertppt = "insert into PptSumFration values(@StudentID,@PaperType,@QuestionTypeID,@sumfartion,@TimeStamp)";
                int numexcel = sqlhelper.ExecuteNonQuery(insertppt, parasinsertPPT, CommandType.Text);
                if (numexcel > 0)
                {
                    return pptsumFrationDt;
                }
                else
                {
                    return null;
                }

            }
            else
            {
                return null;
            }

        }
        #endregion

        #region IE类汇总总分-李芬

        /// <summary>
        /// IE类汇总总分
        /// </summary>
        /// <param name="studentinfo"></param>
        /// <returns></returns>
        public DataTable IEsumfrationdal(String studentID, string TimeTamp)
        {
            String which = selectCollegeID(studentID).ToString();
            //查询学生的试卷类型/类型总分值
            SqlParameter[] IEparas = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                          new SqlParameter("@tamtamp", TimeTamp)};
            string sumText = "select sum(convert(float,fraction)) from IEQuestionRecordEntity_" + which + " where StudentID=@studentID and timeStamp=@tamtamp group by studentID";

            DataTable IEsumFrationDt;
            IEsumFrationDt = sqlhelper.ExecuteQuery(sumText, IEparas, CommandType.Text);
            string sumFration;
            if (IEsumFrationDt.Rows.Count > 0)
            {
                sumFration = IEsumFrationDt.Rows[0][0].ToString();

                //在IESumFration表中插入数据
                //DateTime dtime = System.DateTime.Now
                SqlParameter[] parasinsertIE = new SqlParameter[]{ new SqlParameter("@StudentID",studentID),new SqlParameter("@PaperType","NULL"),new SqlParameter("@QuestionTypeID","NULL"),new SqlParameter("@sumfartion",sumFration),new SqlParameter("@TimeStamp",TimeTamp)
            };
                string insertIE = "insert into IESumFration values(@StudentID,@PaperType,@QuestionTypeID,@sumfartion,@TimeStamp)";
                int numie = sqlhelper.ExecuteNonQuery(insertIE, parasinsertIE, CommandType.Text);
                if (numie > 0)
                {
                    return IEsumFrationDt;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
        #endregion

        #region 选择题类汇总总分-李芬

        /// <summary>
        /// 选择题类汇总总分
        /// </summary>
        /// <param name="studentinfo"></param>
        /// <returns></returns>
        public DataTable Selectsumfration(String studentID, string TimeTamp)
        {
            String which = selectCollegeID(studentID).ToString();
            //查询学生的试卷类型/类型总分值
            SqlParameter[] Selectparas = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                                new SqlParameter("@tamtamp", TimeTamp)};
            string selectsumText = "select sum(convert(float,Fration)) from SelectQuestionRecordEntity_" + which + " where StudentID=@studentID and TimeStamp=@tamtamp group by StudentID";

            DataTable SelectsumFrationDt;
            SelectsumFrationDt = sqlhelper.ExecuteQuery(selectsumText, Selectparas, CommandType.Text);
            string SelectsumFration;
            if (SelectsumFrationDt.Rows.Count > 0)
            {
                SelectsumFration = SelectsumFrationDt.Rows[0][0].ToString();
                //在SelectQuestionRecordEntity表中插入数据
                //DateTime dtime = System.DateTime.Now
                SqlParameter[] parasinsertSelect = new SqlParameter[]{ new SqlParameter("@StudentID",studentID),new SqlParameter("@PaperType","NULL"),new SqlParameter("@QuestionTypeID","NULL"),new SqlParameter("@sumfartion",SelectsumFration),new SqlParameter("@TimeStamp",TimeTamp)
            };
                string insertSelect = "insert into SelectSumFration values(@StudentID,@PaperType,@QuestionTypeID,@sumfartion,@TimeStamp)";
                int numSelect = sqlhelper.ExecuteNonQuery(insertSelect, parasinsertSelect, CommandType.Text);

                if (numSelect > 0)
                {
                    return SelectsumFrationDt;
                }
                else
                {
                    return null;
                }

            }
            else
            {
                return null;
            }


        }
        #endregion

        #region 学生的总成绩汇总-李芬  修改人：李少然 2015年12月20日15:22:21

        /// <summary>
        /// 学生的总成绩汇总
        /// </summary>
        /// <param name="studentinfo"></param>
        /// <returns></returns>
        public DataTable sumfrationdal(String studentID, string TimeTamp, string ExamModel)
        {
            String which = selectCollegeID(studentID).ToString();

            #region 查询学生的姓名-李芬
            //查询学生的姓名
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@studentID", studentID)
                                                       };
            string studentnameText = "select studentName from StudentInfoEntity where StudentID=@studentID ";

            DataTable studentNameDt;
            studentNameDt = sqlhelper.ExecuteQuery(studentnameText, paras, CommandType.Text);
            string studentName;

            if (studentNameDt.Rows.Count > 0)
            {
                studentName = studentNameDt.Rows[0]["studentName"].ToString();
            }
            else
            {
                studentName = "null";
            }

            #endregion

            //查询word中的分数
            #region 查询word中的分数-李芬
            SqlParameter[] wordparas = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                             new SqlParameter("@tamtamp", TimeTamp)};
            string wordsum = "select Fration from WordSumFration where StudentID=@studentID and TimeStamp=@tamtamp";

            DataTable wordsumDt;
            wordsumDt = sqlhelper.ExecuteQuery(wordsum, wordparas, CommandType.Text);
            string wordsumfration;
            if (wordsumDt.Rows.Count > 0)
            {
                wordsumfration = wordsumDt.Rows[0]["Fration"].ToString();
            }
            else
            {
                wordsumfration = "0";
            }
            #endregion

            //查询win中的分数
            #region 查询win中的分数-李芬
            SqlParameter[] winparas = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                             new SqlParameter("@tamtamp", TimeTamp)};
            string winsum = "select Fration from WinSumFration where StudentID=@studentID and TimeStamp=@tamtamp";

            DataTable winsumDt;
            winsumDt = sqlhelper.ExecuteQuery(winsum, winparas, CommandType.Text);
            string winsumfration;
            if (winsumDt.Rows.Count > 0)
            {
                winsumfration = winsumDt.Rows[0]["Fration"].ToString();
            }
            else
            {
                winsumfration = "0";
            }

            #endregion

            //查询选择题中的分数
            #region 查询选择题中的分数-李芬
            SqlParameter[] selectparas = new SqlParameter[] { new SqlParameter("@studentID",studentID),
                                                              new SqlParameter("@tamtamp", TimeTamp)};
            string selectsum = "select Fration from SelectSumFration where StudentID=@studentID and TimeStamp=@tamtamp";

            DataTable selectsumDt;
            selectsumDt = sqlhelper.ExecuteQuery(selectsum, selectparas, CommandType.Text);
            string selectsumfration;
            if (selectsumDt.Rows.Count > 0)
            {
                selectsumfration = selectsumDt.Rows[0]["Fration"].ToString();
            }
            else
            {
                selectsumfration = "0";
            }

            #endregion

            //查询ppt中的分数
            #region 查询ppt中的分数-李芬
            SqlParameter[] pptparas = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                            new SqlParameter("@tamtamp", TimeTamp)};
            string pptsum = "select Fration from PptSumFration where StudentID=@studentID and TimeStamp=@tamtamp";

            DataTable pptsumDt;
            pptsumDt = sqlhelper.ExecuteQuery(pptsum, pptparas, CommandType.Text);
            string pptsumfration;
            if (pptsumDt.Rows.Count > 0)
            {
                pptsumfration = pptsumDt.Rows[0]["Fration"].ToString();
            }
            else
            {
                pptsumfration = "0";
            }

            #endregion

            //查询IE中的分数
            #region 查询IE中的分数-李芬
            SqlParameter[] IEparas = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                            new SqlParameter("@tamtamp", TimeTamp)};
            string IEsum = "select Fration from IESumFration where StudentID=@studentID and TimeStamp=@tamtamp";

            DataTable IEsumDt;
            IEsumDt = sqlhelper.ExecuteQuery(IEsum, IEparas, CommandType.Text);
            string IEsumfration;
            if (IEsumDt.Rows.Count > 0)
            {
                IEsumfration = IEsumDt.Rows[0]["Fration"].ToString();
            }
            else
            {
                IEsumfration = "0";
            }

            #endregion

            #region 查询Excel中的分数-李芬
            //查询Excel中的分数
            SqlParameter[] Excelparas = new SqlParameter[] { new SqlParameter("@studentID", studentID),
                                                              new SqlParameter("@tamtamp", TimeTamp)};
            string Excelsum = "select Fration from ExcelSumFration where StudentID=@studentID and TimeStamp=@tamtamp";

            DataTable ExcelsumDt;
            ExcelsumDt = sqlhelper.ExecuteQuery(Excelsum, Excelparas, CommandType.Text);
            string Excelsumfration;
            if (ExcelsumDt.Rows.Count > 0)
            {
                Excelsumfration = ExcelsumDt.Rows[0]["Fration"].ToString();
            }
            else
            {
                Excelsumfration = "0";
            }

            #endregion

            #region 在总分数的表中插入记录-李芬  修改人：李少然  2015年12月20日15:17:14
            //在总分数的表中插入记录
            float sumFration = float.Parse(Excelsumfration) + float.Parse(IEsumfration) + float.Parse(pptsumfration) + float.Parse(selectsumfration) + float.Parse(winsumfration) + float.Parse(wordsumfration);
            string insertText = "insert into ScoreEntity values(@studentID,@studentName,@SelectScore,@WordScore,@ExcelScore,@IEScore,@WinScore,@PPTScore,@score,@timeSpan,@Collegeid,@ExamModel)";
            //在总成绩表中插入记录。
            SqlParameter[] parasinsert = new SqlParameter[]{new SqlParameter ("@studentID",studentID),
            new SqlParameter("@score",sumFration),new SqlParameter("@SelectScore",selectsumfration),
            new SqlParameter("@WordScore",wordsumfration),new SqlParameter("@ExcelScore",Excelsumfration),
            new SqlParameter("@studentName",studentName),
            new SqlParameter("@timeSpan",TimeTamp),
            new SqlParameter("@IEScore",IEsumfration),
            new SqlParameter("@WinScore",winsumfration),
            new SqlParameter("@PPTScore",pptsumfration),
            new SqlParameter("@Collegeid",which),
            new SqlParameter("@ExamModel",ExamModel)
            };
            sqlhelper.ExecuteNonQuery(insertText, parasinsert, CommandType.Text);
            #endregion

            return studentNameDt;
        }
        #endregion

        #region 查询学生的学院—李芬
        /// <summary>
        /// 查询学生的学院—李芬
        /// </summary>
        /// <param name="studentinfo"></param>
        /// <returns></returns>
        public string selectCollegeID(String studentID)
        {
            SqlParameter[] parascollegeID = new SqlParameter[] { new SqlParameter("@studentID", studentID) };
            string collegeIDText = "select CollegeID from StudentInfoEntity where StudentID=@studentID";
            DataTable collegeDT;
            collegeDT = sqlhelper.ExecuteQuery(collegeIDText, parascollegeID, CommandType.Text);

            string SelectCollegeID;
            if (collegeDT.Rows.Count > 0)
            {
                SelectCollegeID = collegeDT.Rows[0]["CollegeID"].ToString(); return SelectCollegeID;
            }
            else
            {
                return null;
            }




        }

        #endregion

        #region 存入数据库+查询数据库——薛帅行——2018年12月25号17点27分
        public int addScoreAdorn(ScoreAdornEntity scoreAdorn)
        {
            string sql = "insert into ScoreAdornEntity (userId,userName,userCode,totalScore,multipleChoeceRanking,WindowsRanking,WordRanking,ExcelRanking,PPTRanking,IERanking,loginTime,is_Input) values(@userId,@userName,@userCode,@totalScore,@multipleChoeceRanking,@WindowsRanking,@WordRanking,@ExcelRanking,@PPTRanking,@IERanking,@loginTime,@is_Input)";

            SqlParameter[] parasinsert = new SqlParameter[]{new SqlParameter ("@userId",scoreAdorn.userId),
            new SqlParameter("@userName",scoreAdorn.userName),new SqlParameter("@userCode",scoreAdorn.userCode),
            new SqlParameter("@totalScore",scoreAdorn.totalScore),new SqlParameter("@multipleChoeceRanking",scoreAdorn.multipleChoeceRanking),
            new SqlParameter("@WindowsRanking",scoreAdorn.WindowsRanking),
            new SqlParameter("@WordRanking",scoreAdorn.WordRanking),
            new SqlParameter("@ExcelRanking",scoreAdorn.ExcelRanking),
            new SqlParameter("@PPTRanking",scoreAdorn.PPTRanking),
            new SqlParameter("@IERanking",scoreAdorn.IERanking),
            new SqlParameter("@loginTime",scoreAdorn.loginTime),
            new SqlParameter("@is_Input","1")
            };
            return sqlhelper.ExecuteNonQuery(sql, parasinsert, CommandType.Text);
        }

        public DataTable inquiryScore(ScoreEntity score)
        {
            string sql = "select top 1 * from ScoreEntity where studentID=@studentID order by timeSpan DESC ";

            SqlParameter[] paras = new SqlParameter[]{new SqlParameter ("@studentID",score.studentID) };
            return sqlhelper.ExecuteQuery(sql, paras, CommandType.Text);
        }


        /// <summary>
        /// 查询当天时间并且没有推送出去所有字段
        /// </summary>
        /// <param name="score"></param>
        /// <returns></returns>
        public DataTable inquiryScoreAdorn(ScoreAdornEntity score)
        {
            //获取数据库当天时间
            //查询时间格式为yyyy-MM-dd
            string sqltime = "Select convert(varchar(10),getdate(),120)";
            DataTable table = sqlhelper.ExecuteQuery(sqltime, CommandType.Text);
            string date = table.Rows[0][0].ToString();       
            
            //执行查询
            string sql = "select * from ScoreAdornEntity where is_Input = @is_Input and  datediff(day,loginTime,@date)=0";  //代码适用Win7
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@is_Input", "1"),
            new SqlParameter("@date",date)};
            return sqlhelper.ExecuteQuery(sql, paras, CommandType.Text);
        }


        /// <summary>
        /// 修改推送为已推送
        /// </summary>
        /// <param name="scoreAdorn"></param>
        /// <returns></returns>
        public int UpdateScoreAdorn(ScoreAdornEntity scoreAdorn)
        {
            string sql = "update ScoreAdornEntity set is_Input=@is_Input where userId=@userId ";

            SqlParameter[] parasinsert = new SqlParameter[]{
                new SqlParameter ("@userId",scoreAdorn.userId),
                new SqlParameter("@is_Input","0")                
            };
            return sqlhelper.ExecuteNonQuery(sql, parasinsert, CommandType.Text);
        }

        //UPDATE Person SET FirstName = 'Fred' WHERE LastName = 'Wilson'



        /// <summary>
        /// 用于显示交卷的第一条记录
        /// </summary>
        /// <param name="score"></param>
        /// <returns></returns>
        public List<ScoreAdornEntity>inquiryScoreAdorn_Isinput(ScoreAdornEntity score)
        {
            string sql = "select * from ScoreAdornEntity where is_Input = @is_Input";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@is_Input", "1"),
                new SqlParameter("@userId",score.userId)};
            DataTable dt= sqlhelper.ExecuteQuery(sql, paras, CommandType.Text);

            List<ScoreAdornEntity> isSelectScoreAdorn = new List<ScoreAdornEntity>();
            isSelectScoreAdorn = dtToScoreAdorn.ToList(dt);
            return isSelectScoreAdorn;
        }

        #endregion

    }
}
